package com.hbnu.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hbnu.system.core.base.CommonPage;
import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.dto.CheckBackDTO;
import com.hbnu.system.model.dto.SearchPageDTO;
import com.hbnu.system.model.dto.UserDTO;
import com.hbnu.system.model.entity.Meeting_join;
import com.hbnu.system.service.IMeeting_joinService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/meeting_join")
@Api(tags = "参与会议模块")
public class Meeting_joinController {
    @Autowired
    IMeeting_joinService iMeeting_joinService;
    @ApiOperation("参与会议录入")
    @PostMapping("/addJoinMeeting")
    public Rest<Boolean> AddJoinmeeting(@RequestBody Meeting_join meeting_join){
        boolean add = iMeeting_joinService.addmeetjoin(meeting_join);
        return add ? Rest.success() : Rest.failed();
    }
    @ApiOperation("参与会议删除")
    @GetMapping("/DeleteJoinMeeting")
    public Rest<Boolean> DeletejoinMeeting(String ID){
        boolean delete = iMeeting_joinService.deletemeetjoin(ID);
        return delete ? Rest.success() : Rest.failed();
    }
    @ApiOperation("参与会议提交")
    @GetMapping("/ReCommitJoinMeeting")
    public Rest<Boolean> ReCommitJoinMeeting(String ID){
        boolean add = iMeeting_joinService.ReCommitMeetingjoin(ID);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("参与会议修改")
    @PostMapping("/UpdateJoinMeeting")
    public Rest<Boolean> UpdateJoinMeeting(@RequestBody Meeting_join meeting_join){
        boolean delete = iMeeting_joinService.updatemeetjoin(meeting_join);
        return delete ? Rest.success() : Rest.failed();
    }


    @ApiOperation("参与会议名称查重")
    @GetMapping("/CheckJoinMeetingName")
    public Rest<Boolean> CheckJoinMeetingName(String name){
        boolean check = iMeeting_joinService.checkmeetjoinName(name);
        return check ? Rest.success() : Rest.failed();
    }
    @ApiOperation("根据主键参与会议查询")
    @GetMapping("/GetJoinMeetingById")
    public Rest<Meeting_join> GetjoinMeetingById(String ID){
        Meeting_join mt = iMeeting_joinService.getmeetjoinbyid(ID);
        return Rest.success(mt);
    }
    @ApiOperation("参与会议分页查询")
    @PostMapping ("/pagecondition")
    public Rest<CommonPage<Meeting_join>> pageProjectCondition(@RequestBody SearchPageDTO searchTaskDTO){
        IPage<Meeting_join> page = iMeeting_joinService.pageCondition(searchTaskDTO);
        CommonPage<Meeting_join> activityVOCommonPage = CommonPage.restPage(page);
        return Rest.success(activityVOCommonPage);
    }
    @ApiOperation("参与会议校级通过")
    @GetMapping("/SchoolCheckPass")
    public Rest<String> SchoolPassmeetingjoin(@RequestHeader("X-Token") String token,String PID){
        Boolean b = iMeeting_joinService.schoolCheckPass(token,PID);
        return b ? Rest.success() : Rest.failed();
    }
    @ApiOperation("参与会议校级打回")
    @PostMapping("/SchoolCheckBack")
    public Rest<String> SchoolBackmeetingjoin(@RequestHeader("X-Token") String token,@RequestBody CheckBackDTO checkBackDTO){
        Boolean b = iMeeting_joinService.schoolCheckBack(token,checkBackDTO);
        return b ? Rest.success() : Rest.failed();
    }
    @ApiOperation("用户获取与自己相关的参与会议分页")
    @PostMapping("/UserGetRelatejoinMeeting")
    public Rest<CommonPage<Meeting_join>> UserGetRelatejoinmeeting(@RequestBody UserDTO userDTO){
        IPage<Meeting_join> mtIPage = iMeeting_joinService.userGetRelatejoinmeeting(userDTO);
        CommonPage<Meeting_join> mtCommonPage = CommonPage.restPage(mtIPage);
        return Rest.success(mtCommonPage);
    }
    @ApiOperation("校级管理员查看需要自己审核的参与会议分页")
    @PostMapping("/SchoolUserGetjoinMeeting")
    public Rest<CommonPage<Meeting_join>> SchoolUserGetjoinmeeting(@RequestBody UserDTO userDTO){
        IPage<Meeting_join> mtIPage = iMeeting_joinService.schoolUserGetjoinmeeting(userDTO);
        CommonPage<Meeting_join> mtCommonPage = CommonPage.restPage(mtIPage);
        return Rest.success(mtCommonPage);
    }
}

